/**
 * 1935. 可以输入的最大单词数
 * https://leetcode-cn.com/problems/maximum-number-of-words-you-can-type/
 */
public class Solutions_1935 {
    public static void main(String[] args) {
//        String text = "hello world", brokenLetters = "ad";  // output: 1
//        String text = "leet code", brokenLetters = "lt";  // output: 1
        String text = "leet code", brokenLetters = "e";  // output: 0

        int result = canBeTypedWords(text, brokenLetters);
        System.out.println(result);
    }

    public static int canBeTypedWords(String text, String brokenLetters) {
        boolean[] map = new boolean[26];
        for (int i = 0; i < brokenLetters.length(); i++) {
            map[brokenLetters.charAt(i) - 'a'] = true;
        }
        String[] words = text.split(" ");
        int res = 0;
        for (String word : words) {
            for (int i = 0; i < word.length(); i++) {
                if (map[word.charAt(i) - 'a']) {
                    break;
                }
                if (i == word.length() - 1) {
                    res ++;
                }
            }
        }
        return res;
    }
}
